//
//  ViewController.m
//  Camera
//
//  Created by gml on 2018/9/28.
//  Copyright © 2018年 gml. All rights reserved.
//

#import "ViewController.h"
#import "UIImage+ImageEffects.h"
#import "CameraViewController.h"
#import "AnimationViewController.h"
#import "HitTestViewController.h"
#import "TaoBaoViewController.h"
#import "TouchIDViewController.h"
#import "ADCellViewController.h"
#import "GMLHomeViewController.h"
#import "LoadingViewController.h"
#import "ShareViewController.h"
#import "CoreDataViewController.h"
#import "LayoutViewController.h"
#import "PushViewController.h"
#import "StudyViewController.h"
#import "DynamicViewController.h"
#import "QMIMViewController.h"

#import "MJRefresh.h"



@interface ViewController ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate>
@property (nonatomic,strong) UITableView *tableiew;
@property (nonatomic,strong) NSArray *list;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableiew];
    
    // document路径
    NSString *docFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    // library路径
    NSString *libFilePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
    
    // cache路径
    NSString *cacheFilePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];

    // tmp路径
    NSString *tmpFilePath = NSTemporaryDirectory();
    
   static int a = 10;
    int b = 10;
    void(^Block)(void) = ^{
        NSLog(@"a = %d  b= %d",a,b);
    };
    a = 20;
    Block();
    void(^block2)(void) = ^{
         NSLog(@"hello world");
    };
    
    NSLog(@"%@ -- %@",[Block class],[block2 class]);
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"numberOfSectionsInTableView");
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    cell.textLabel.text = _list[indexPath.row];
    NSLog(@"---cellForRowAtIndexPath");
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"---heightForRowAtIndexPath");
    return 44;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     Class nextClass = NSClassFromString(_list[indexPath.row]);
    UIViewController *nextVC = [[nextClass alloc] init];
    [self.navigationController pushViewController:nextVC animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"---numberOfRowsInSection");
    return self.list.count;
}

-(UITableView *)tableiew
{
    if (_tableiew == nil) {
        _tableiew = [[UITableView alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.bounds.size.height, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - self.navigationController.navigationBar.bounds.size.height) style:UITableViewStylePlain];
        _tableiew.delegate = self;
        _tableiew.dataSource = self;
        [_tableiew registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
        _tableiew.estimatedRowHeight = 0;
        
    }
    return _tableiew;
}
- (NSArray *)list
{
    if (_list == nil) {
        _list = @[NSStringFromClass([CameraViewController class]),
                  NSStringFromClass([AnimationViewController class]),
                  NSStringFromClass([HitTestViewController class]),
                  NSStringFromClass([TaoBaoViewController class]),
                  NSStringFromClass([TouchIDViewController class]),
                  NSStringFromClass([ADCellViewController class]),
                  NSStringFromClass([GMLHomeViewController class]),
                  NSStringFromClass([LoadingViewController class]),
                  NSStringFromClass([ShareViewController class]),
                  NSStringFromClass([CoreDataViewController class]),
                  NSStringFromClass([LayoutViewController class]),
                  NSStringFromClass([PushViewController class]),
                  NSStringFromClass([StudyViewController class]),
                  NSStringFromClass([DynamicViewController class]),
                  NSStringFromClass([QMIMViewController class])];
    }
    return _list;
}


@end
